function test(){
    var myp = document.getElementById("myp");
    var str;
    var score = document.getElementById("score").value;
    
    if(score<0){
        str = "分数不能为负";
        myp.innerHTML=str;
        return;
    }
    if(score<60){
        str = "不及格";
        myp.innerHTML=str;
        return;
    }
    if(score<80){
        str = "及格";
        myp.innerHTML=str;
        return;
    }
    if(score<90){
        str="良好";
        myp.innerHTML=str;
        return;
    }
    if(score<100){
        str="优秀";
        myp.innerHTML=str;
        return;
    }
    
}

var o = {
    name:"张珊",
    say:function(){
        console.log(this.name);
        
    }
}

o.say();

function add(x,y){
    return x+y;
}

function substract(x,y){
    return x-y;
}

function operate(operator,num1,num2){
   return operator(num1,num2);
}


console.log(operate(add,3,2));
console.log(operate(substract,3,2));


console.log("----------------");
var opt={
    add:function(x,y){return x+y;},
    substract:function(x,y){return x-y;}
}
function op(opn,n1,n2){
    if(typeof opt[opn] === "function"){
        return opt[opn](n1,n2);
    }else{
        throw "unkonwn result";
    }

}

var redult = op("add",2,3);
console.log(redult);


console.log("-------");
function compare(x,y){
    return x-y;
}
var arr = [1,2,5,3,4];
console.log(arr.sort(compare));




